package com.kk.miaosha.config;

import com.kk.miaosha.security.config.SecurityConfig;
import com.kk.miaosha.securityEntity.UserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @author : K k
 * @date : 19:01 2020/10/21
 */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MySecurityConfig extends SecurityConfig {
    @Autowired
    private UserDetailService userDetailService;

    @Bean
    public UserDetailsService userDetailsService() {
        //获取登录用户信息
        return username -> userDetailService.loadUserByUsername(username);
    }
}
